package com.orangelife.exception;

public class MyException extends Exception {
	/**
	 * 
	 */
	private static final long serialVersionUID = 8965433624249925129L;

	public MyException() {
		super();
	}

	public MyException(String message) {
		super(message);
	}

	public MyException(String message, Throwable cause) {
		super(message, cause);
	}

	public MyException(Exception ex) {
		super(ex);
	}

	public String getErrorinfo() {
		return this.GetErrorWord(this.getMessage());
	}

	/**
	 * 返回由数据库返回的错误，过滤@@和##之间的文字
	 * 
	 * @param msg
	 *            错误信息
	 * @return 过滤后的错误提示
	 */
	public String GetErrorWord(String msg) {
		int start = 0, end = 0;
		if (msg == null || "".equals(msg))
			return "";
		start = msg.indexOf("@@");
		if (start != -1) {
			end = msg.indexOf("##", start);
			if (start < end)
				return msg.substring(start + 2, end);
			return "";
		}
		return msg.replace("\r\n", "\\n");
	}
}
